package com.block.api.controller.channel;

import com.alibaba.fastjson.JSONObject;
import com.block.common.constant.AppRspCodeConstant;
import com.block.common.exception.ApiException;
import com.block.common.security.util.ApiUtil;
import com.block.common.vo.ResponseVo;
import com.block.db.entity.AppEncrypt;
import com.block.db.entity.ApplicationInfo;
import com.block.db.entity.ChannelBaseInfo;
import com.block.product.service.IProductOnlieInfoService;
import com.block.product.service.IProductProfitUvInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("api/channel")
@Validated
public class ChannelController {

    @Autowired
    IProductOnlieInfoService productOnlieInfoService;
    @Autowired
    IProductProfitUvInfoService productProfitUvInfoService;

    /**
     * 产品列表信息
     */
    @RequestMapping(value = "/baseInfo", method = {RequestMethod.POST, RequestMethod.GET})
    public String baseInfo(@RequestAttribute(value = "tranData") JSONObject tranData,
                               @RequestAttribute(value = "appEncrypt") AppEncrypt appEncrypt,
                               @RequestAttribute(value = "channelBaseInfo") ChannelBaseInfo channelBaseInfo,
                               @RequestAttribute(value = "applicationInfo") ApplicationInfo applicationInfo,
                               @RequestAttribute(value = "uri") String uri,
                               @RequestAttribute(value = "startDate") Date startdate,
                               @RequestAttribute(value = "ip") String ip) throws ApiException {

        JSONObject returnData = new JSONObject();
        returnData.put("channelCode", channelBaseInfo.getChannelCode());
        returnData.put("channelName", channelBaseInfo.getChannelName());
        returnData.put("smsFlag", channelBaseInfo.getSmsFlag());
        returnData.put("pageType", channelBaseInfo.getPageType());
        returnData.put("chargeType", channelBaseInfo.getChargeType());

        ResponseVo responseVo = new ResponseVo(AppRspCodeConstant.SUCCESS, returnData);
        return ApiUtil.dealReturnJson(responseVo, appEncrypt, startdate, uri);
    }


}